import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { Menu, MenuService } from '@delon/theme';

@Component({
	selector: 'app-menuloading',
	templateUrl: './menuloading.component.html',
	styles: [],
})
export class MenuloadingComponent implements OnInit {
	constructor(private menuService: MenuService, private router: Router) {}

	ngOnInit(): void {
		const menuList: Menu[] = this.menuService.menus;
		if (menuList.length === 0) {
			return;
		}
		if (menuList[0].children!.length) {
			this.router.navigateByUrl(menuList[0].children![0]['path']);
		} else {
			this.router.navigateByUrl(menuList[0]['path']);
		}
	}
}
